package com.example.utils;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayTradePagePayRequest;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 游家纨绔
 * @dateTime 2023-09-09 00:00
 * @apiNote TODO 提供支付宝相关的一些对象
 */
@Configuration
public class BeanUtils {

	// 创建支付宝需要的客户端对象
	@Bean
	public AlipayClient alipayClient() {
		return new DefaultAlipayClient(AppUtils.gatewayUrl, AppUtils.app_id
				                     , AppUtils.merchant_private_key, "json"
				                     , AppUtils.charset, AppUtils.alipay_public_key
				                     , AppUtils.sign_type
		);
	}

	// 创建一个支付宝的请求对象
	@Bean
	public AlipayTradePagePayRequest alipayTradePagePayRequest() {
		return new AlipayTradePagePayRequest();
	}

}
